using System;
using System.Collections.Generic;
using System.Windows.Media;

namespace 地图哇哇哇
{
    public class ColorGenerator
    {
        /// <summary>Gets a random color based on RGB</summary>
        /// <returns>Color object</returns>
        public static Color GetColor(byte alpha = 255)
        {
            var ran = new Random(Guid.NewGuid().GetHashCode());
            var bs = new byte[3];
            ran.NextBytes(bs);
            return Color.FromArgb(alpha, bs[0], bs[1], bs[2]);
        }

        /// <summary>Get a collection of random colors based on RGB</summary>
        /// <param name="quantity">Number of elements of the collection. The value must be greater than or equal to 0</param>
        /// <param name="alpha"></param>
        /// <returns>Collection of colors (Type Color). By default it returns a collection with 5 colors</returns>
        public static List<Color> GetColorsCollection(int quantity = 5, byte alpha = 255)
        {
            List<Color> colorList = new List<Color>();
            for (int index = 0; index < quantity; ++index)
            {
                var color = GetColor(alpha);
                if (!colorList.Contains(color))
                    colorList.Add(color);
                else
                    --index;
            }

            return colorList;
        }
    }
}